package com.shanghaionstar.activity.webview.handler.picture;

import android.content.Context;
import android.widget.Toast;

/**
 * &lt;一句话功能简述&gt; &lt;功能详细描述&gt;
 *
 * @author xuff
 * @version [版本号, 2015/11/26]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class ToastUtils {
    private static Toast toast = null;

    public static synchronized void showToast_Short(Context context, String content) {
        if (context == null)
            return;
        if (toast == null) {
            toast = Toast.makeText(context, content, Toast.LENGTH_SHORT);
        } else {
            toast.cancel();
            toast = Toast.makeText(context, content, Toast.LENGTH_SHORT);

            toast.setText(content);
            toast.setDuration(Toast.LENGTH_SHORT);
        }
        toast.show();
    }

    public static synchronized void showToast_Short(Context context, int content) {
        if (context == null)
            return;
        if (toast == null) {
            toast = Toast.makeText(context, content, Toast.LENGTH_SHORT);
        } else {
            toast.cancel();
            toast = Toast.makeText(context, content, Toast.LENGTH_SHORT);
            toast.setText(content);
            toast.setDuration(Toast.LENGTH_SHORT);

        }
        toast.show();
    }

    public static synchronized void showToast_Long(Context context, String content) {
        if (context == null)
            return;
        if (toast == null) {
            toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
        } else {
            toast.cancel();
            toast = Toast.makeText(context, content, Toast.LENGTH_LONG);

            toast.setText(content);
            toast.setDuration(Toast.LENGTH_LONG);
        }
        toast.show();
    }

    public static synchronized void showToast_Long(Context context, int content) {
        if (context == null)
            return;
        if (toast == null) {
            toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
        } else {
            toast.cancel();
            toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
            toast.setText(content);
            toast.setDuration(Toast.LENGTH_LONG);
        }
        toast.show();
    }
}
